Controller path for nested resource - undefined method `<controller>_path'

Posted by owilde1900 on Stack Overflow See other posts from Stack Overflow or by owilde1900
Published on 2010-12-24T19:06:42Z Indexed on 2010/12/24 23:54 UTC
Read the original article Hit count: 131

Filed under:

I'm having trouble displaying my form at /users/2/friends/new. I'm receiving

undefined method `friends_path' for #<#<Class:0x21f0c14>:0x21ef364>

Here is the beginning of the form

<% form_for(@friend) do |f| %> 

And the friends controller

def new
     @user = User.find(params[:user_id])
     @friend = @user.friends.build
end

This is the route

resources :users do
       resources :friends
end

And the relevant path from "rake routes"

users/:user_id/friends/new(.:format)      {:controller=>"friends", :action=>"new"}

Any help or insight is greatly appreciated. This is my first rails 3 app.

© Stack Overflow or respective owner

Related posts about ruby-on-rails3